﻿//Tzi Yong

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace Tzync
{
    public partial class AboutUIForm : Form
    {
        public AboutUIForm()
        {
            InitializeComponent();
        }

        private void AboutUIForm_Load(object sender, EventArgs e)
        {
            updateBtnToolTip.SetToolTip(updateBtn, "Click here to check for updates to Tzync online");
            closeBtnToolTip.SetToolTip(closeBtn, "Click here to go back to Profiles");
        }

        private void updateBtn_Click(object sender, EventArgs e)
        {
            try
            {
                String updateURL = Utility.CheckForUpdate();    //check for updates online
                
                if (!updateURL.Equals(""))
                {
                    DialogResult result = MessageBox.Show("A new version of Tzync has been detected!\n\nDo you want to visit Tzync's website for more information?", "New version of Tzync found!",
                                            MessageBoxButtons.YesNo,
                                            MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                        Process.Start(updateURL);   //open web browser to download latest version
                    else
                        return;

                }
                else
                {
                    MessageBox.Show("No newer version found.\n\nYou are using the latest version of Tzync!", "No new version found",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Information);
                }

            }
            catch (Exception)
            {
                MessageBox.Show("An error occurred while checking for updates!\n\nPlease check your internet connection and try again.", "Oops!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        private void closeBtn_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void groupLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://groups.google.com.sg/group/tzync");
        }

        private void webLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("http://code.google.com/p/tzync/");
        }

        private void emailLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            Process.Start("mailto:tzync@googlegroups.com");
        }
    }
}
